/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package EntidadesBD;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author ROCIO
 */
@Entity
@Table(name = "plan", catalog = "secdux", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Plan.findAll", query = "SELECT p FROM Plan p"),
    @NamedQuery(name = "Plan.findByCodigoPlan", query = "SELECT p FROM Plan p WHERE p.codigoPlan = :codigoPlan"),
    @NamedQuery(name = "Plan.findByPrograma", query = "SELECT p FROM Plan p WHERE p.programa = :programa")})
public class Plan implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "CodigoPlan", nullable = false)
    private Integer codigoPlan;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "Programa", nullable = false, length = 50)
    private String programa;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "plan")
    private List<Contratodemateria> contratodemateriaList;

    public Plan() {
    }

    public Plan(Integer codigoPlan) {
        this.codigoPlan = codigoPlan;
    }

    public Plan(Integer codigoPlan, String programa) {
        this.codigoPlan = codigoPlan;
        this.programa = programa;
    }

    public Integer getCodigoPlan() {
        return codigoPlan;
    }

    public void setCodigoPlan(Integer codigoPlan) {
        this.codigoPlan = codigoPlan;
    }

    public String getPrograma() {
        return programa;
    }

    public void setPrograma(String programa) {
        this.programa = programa;
    }

    @XmlTransient
    public List<Contratodemateria> getContratodemateriaList() {
        return contratodemateriaList;
    }

    public void setContratodemateriaList(List<Contratodemateria> contratodemateriaList) {
        this.contratodemateriaList = contratodemateriaList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (codigoPlan != null ? codigoPlan.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Plan)) {
            return false;
        }
        Plan other = (Plan) object;
        if ((this.codigoPlan == null && other.codigoPlan != null) || (this.codigoPlan != null && !this.codigoPlan.equals(other.codigoPlan))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "EntidadesBD.Plan[ codigoPlan=" + codigoPlan + " ]";
    }
    
}
